<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
<head>
<link rel="stylesheet" href="<%=path%>/css/manager/organization2.css">
<script type="text/javascript"
	src="<%=path%>/js/manager/jquery-1.8.2.js"></script>
<script type="text/javascript"
	src="<%=path%>/js/manager/organization.js"></script>
<title>论坛管理-编辑机构</title>
</head>
<body>

	<!--
        	作者：offline
        	时间：2016-12-22
        	描述：论坛内容头部（统一，部分二级字体颜色单独修改）
        -->
	<div class="news_div1">
		<div class="news_div1_div1">论坛管理</div>
		<div class="news_div1_div2">
			<a href="<%=path%>/basicctr/bbsbasic.htm?markManage=3"
				class="news_div1_div2_div1">论坛概况</a> <a>|</a> <a href="###"
				class="news_div1_div2_div2 ablack">机构设置</a> <a>|</a> <a
				href="<%=path%>/newsctr/newslist.htm?pageIndex=1&pageSize=10&newsType=4"
				class="news_div1_div2_div3">理事动态</a>
		</div>
	</div>
	<!--内容-->
	<div class="organization2_div1">
		<form action="" id="sform" method="post">
			<input type="hidden" id="sysuserId" name="orgAdduser"
				value="${back_user.sysuserId}" /> <input type="hidden"
				id="markManage" name="markManage" value="3" /> <input type="hidden"
				id="pageIndex" name="pageInfo.pageIndex"
				value="${organize.pageInfo.pageIndex}" /> <input type="hidden"
				id="pageSize" name="pageInfo.pageSize"
				value="${organize.pageInfo.pageSize}" /><input type="hidden"
				id="orgId" name="orgId" value="${organize.orgId}" /> <input
				type="hidden" id="orgName" name="orgName"
				value="${organize.orgName}" /> <input type="hidden" id="orgContent"
				name="orgContent" value="${organize.orgContent}" />
			<div class="bbs_div1_div1">
				<span class="bbs_div1_div1_sp1">机构设置详情</span> <input
					class="bbs_div1_div1_in1" type="button"
					onclick="manage('${organize.orgContent}')" />
			</div>
			<div class="organization2_div1_div1">
				<div class="organization2_div1_div1_div1">机构名称</div>
				<div class="organization2_div1_div1_div2">
					<div>${organize.orgName}</div>
				</div>
			</div>
			<div class="organization2_div1_div2">
				<div class="organization2_div1_div2_div1">机构内部名称</div>
				<div class="organization2_div1_div2_div2">
					<c:forEach items="${organize.listContent}" var="name">
						<div>${name}</div>
					</c:forEach>
				</div>
				<div class="clearboth"></div>
			</div>
			<input type="hidden" id="pageSize" name="pageSize"
				value="${organize.pageInfo.pageSize}" /> <input type="submit"
				class="organization2_div1_div3" value="返回列表" onclick="return back()" />
		</form>
	</div>
	<!--机构添加-->
	<div class="organization">
		<div class="organization_div1">
			<div class="organization_div1_div1">编辑机构</div>
			<div class="organization_div1_div2">
				<div class="organization_div1_div2_div1">机构名称</div>
				<input class="organization_div1_div2_in1" type="text"
					placeholder="机构名称" id="orgName_sel" value="${organize.orgName}" />
			</div>
			<div class="organization_div1_div3">
				<div class="organization_div1_div3_div1">机构内部名称</div>
				<div class="organization_div1_div3_div2">
					<c:forEach items="${organize.listContent}" var="name">
						<input type="text" placeholder="机构内部名称（一次仅输入一个)" value="${name}"
							name="content" />
					</c:forEach>
				</div>
				<div class="clearboth"></div>
			</div>
			<input class="organization_div1_in1" type="button" />
			<div class="organization_div1_div4">
				<input class="organization_div1_div4_in1" type="button"
					onclick="submitCheck()" /> <input
					class="organization_div1_div4_in2" type="button" />
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
//编辑
function manage(content){
	     
		$("#markManage").val(2);
		$(".organization_div1_div3_div2").html("");
		if(content.length==0){
			$(".organization_div1_div3_div2").append($('<div class="organization_div1_div3_div2_div1"><input type="text" placeholder="机构内部名称（一次仅输入一个)" value="" name="content"/></div>'));
			return ;	
		}
		var array=content.split("@##");
		for(var i=0;i<array.length;i++){
			if(i==0){
			$(".organization_div1_div3_div2").append($('<div class="organization_div1_div3_div2_div1"><input type="text" placeholder="机构内部名称（一次仅输入一个)" value="'+array[i]+'" name="content"/></div>'));
			}else{
			$(".organization_div1_div3_div2").append($('<div class="organization_div1_div3_div2_div1"><input type="text" placeholder="机构内部名称（一次仅输入一个)" value="'+array[i]+'" name="content"/><img class="organization_div1_div3_div2_div1_img1" src="<%=path%>/images/manager/organization_03s.jpg" /></div>'));
			}
		}	
		tianjia();
	
}
//提交验证
function submitCheck(){
	//验证管理员登录
	var sysuserId=$("#sysuserId").val();
	if(sysuserId.length==0){
		alert("管理员登录失效，请重新登录");
		window.open("<%=path%>/login/beforelogin.htm");
			return false;
		}
		//验证机构
		var orgName = $("#orgName_sel").val();
		if (orgName.length == 0) {
			alert("机构名称不能为空！");
			$("#orgName_sel").focus();
			return false;
		} else {
			$("#orgName").val(orgName);
		}
		//内部机构
		var array = document.getElementsByName("content");
		var content = "";
		for (var i = 0; i < array.length; i++) {
			if (array[i].value.length > 0) {
				content = content + array[i].value + "@##";
			}
		}
		content = content.substring(0, content.length - 3);
		if (content.length > 0) {
			$("#orgContent").val(content);
		}
		$("#pageIndex").attr("name","pageInfo.pageIndex");  
		$("#pageSize").attr("name","pageInfo.pageSize");  
		$("#sform").attr("action", "omanage.htm");
		$("#sform").submit();

	}
	//返回
	function back() {
		$("#sform").attr("action", "olist.htm");
		$("#sform").submit();
	}
</script>
</html>

